/**
 * Created by ss on 16/4/10.
 */
var $ = require('jquery');
var init = require('../util/init.js');
var util = require('../util/util.js');
var templateUtil = require('../util/templateUtil.js');
var tpl = require('../../tpl/corpItem.tpl');
var bigBottomButton = require('../component/common/bigBottomButton.js');
var corpList = JSON.parse(require('../../json/corpJSON.json'));
require('../../scss/addReceive.scss');

init.initNav(true, '添加收件');
$("#typeChoose").html(templateUtil.template(tpl, {list: corpList}));
bigBottomButton.init($("#bottomButton"), "http://d3.freep.cn/3tb_16052510285599oq564060.png", "确定");
$("#typeChoose li").click(function () {
    $("#typeChoose li").removeClass("on");
    $(this).addClass("on");
});
//window.onhashchange =  function () {
//    var hash = window.location.hash;
//    switch (hash) {
//        case "#chooseCorp":
//            $("#typeChoose").addClass("show");
//    }
//};
$("#bottomButton").click(function () {
    //window.location.href = "#chooseCorp";
    //return false;
    var dom = util.showLoading();
    var nu = $("input[name='id']").val();
    var type = $("#typeChoose li.on").attr("data-com");
    var post = {
        nu: nu,
        type: type,
        phone: util.getUserStore()
    };
    $.get(util.getAjaxUrl("/addReceive"), post, function (data) {
        dom.remove();
        if (data.code === 0) {
            alert(data.errorInfo);
            //util.changePage("./index");
        } else {
            util.changePage('./index');
        }
    });
});





